﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Collections;
using Microsoft.ApplicationBlocks.Data;
using System.Diagnostics;
using System.Threading;
using SysSet;
namespace kxjsj
{
    public partial class ShowPreForm : Form
    {
        public ShowPreForm()
        {
            InitializeComponent();
            string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + System.Windows.Forms.Application.StartupPath + "\\data\\kxjsj.mdb";
            con = new OleDbConnection(constr);
            con.Open();
        }
        public string sql = "";
        OleDbConnection con;
        private void ShowFormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }
 
        private void ShowPreForm_Load(object sender, EventArgs e)
        {
            OleDbDataAdapter sda = new OleDbDataAdapter(sql, con);
            DataSet ds = new DataSet();
            sda.Fill(ds, "huizong");
            this.dataGridView1.DataSource = ds.Tables["huizong"].DefaultView;
        }

        private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {

        }

        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string id="", name="";
            if (e.ColumnIndex == 1)
            {
                id = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                name = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
            }
            if (id != "" && name != "")
            { 
                //读取pdf，写入临时目录，用foxit打开
                db_helper.get_pdf_from_db(con, "full_paper", id, name);
                //Process p = new Process();
                //string proc = System.Windows.Forms.Application.StartupPath + "\\PDF\\Foxit Reader.exe";
                //ProcessStartInfo psi = new ProcessStartInfo(proc);
                //psi.UseShellExecute = false;
                //psi.Arguments = " -NoRegister " + System.Windows.Forms.Application.StartupPath + "\\" + id + "\\" + name + ".pdf";
                //p.StartInfo = psi;
                //p.Start();
                helper.show_pdf(System.Windows.Forms.Application.StartupPath + "\\" + id + "\\" + name + ".pdf");
            }
        }

     }
}
